package cn.com.xf.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.com.xf.dao.SmsToAppDAO;
import cn.com.xf.dao.support.XFSqlMapClientDaoSupport;
import cn.com.xf.domain.BatDstarea;
import cn.com.xf.domain.SmsToApp;
import cn.com.xf.domain.Tbareainfo;
import cn.com.xf.domain.VDstarea;
import cn.com.xf.service.impl.NoticeServiceImpl;

@Repository
public  class SmsToAppDAOImpl extends XFSqlMapClientDaoSupport implements SmsToAppDAO {
	Log log = LogFactory.getLog(SmsToAppDAOImpl.class);
	

	@Override
	public void insert(SmsToApp record) {
		getSqlMapClientTemplate().insert("SMS_TOAPP.ibatorgenerated_insert", record);
		
		
	}

	@Override
	public int insertBatch(List<SmsToApp> list) {
		int count = 0;
		try {
			// 自己控制事物的开始
			getSqlMapClient().startTransaction();
			getSqlMapClient().startBatch();
			for (SmsToApp s : list) {
				try {
					getSqlMapClientTemplate().insert("SMS_TOAPP.ibatorgenerated_insert", s);
					count = getSqlMapClient().executeBatch();
					getSqlMapClient().commitTransaction();
				} catch (SQLException e) {
					log.error("SMS_TOAPP.insertBatch数据插入错误:"+e.getMessage());
				}
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// 自己控制事物的结束
			try {
				getSqlMapClient().endTransaction();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return count;
	}

	
}
